import React, { useContext } from 'react'
import { ThemeContext } from '../App'
interface IHelloProps {
  // 可选属性
  message ?: string;
}
// const Hello = (props: IHelloProps) => {
//   return <h2>{props.message}</h2>
// }

// React.FC是React.FunctionComponent的类型别名
const Hello: React.FC<IHelloProps> = (props) => {
  const theme = useContext(ThemeContext)
  const style = {
    color: theme.color,
    background: theme.background
  }
  return <h2 style={style}>{props.message}</h2>
}
// 组件的默认属性
Hello.defaultProps = {
  message: "hello typescript"
}
export default Hello;